package com.bw.interceptor;

import com.bw.domain.User;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author :Beyond🎸🎸
 * @date : 2025-02-28 19:39:52
 * @description
 **/
public class LoginInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

        User userInfo = (User) request.getSession().getAttribute("userInfo");

        if(userInfo!=null){
            return true;
        }else{
            response.sendRedirect("/login/tologin.do");
            return false;
        }
    }
}
